<?php
class Controller_Admin_Hotword extends Controller_Template
{
	public function __construct($request,$response)
	{
		header("Content-Type:text/html;charset=utf-8"); 
		parent::__construct($request,$response);
		$this->template	= ('smarty:admin/home/index');
	}

	public function action_index()
	{
		$words	= Hotword::get_allwords();
		$this->template->set_filename('smarty:admin/home/index');
		$this->template->set('str', $words);
		$this->template->set('function_name', 'hotword');
		$this->template->set('page_title', '热门关键词');
		$this->response->body($this->template->render());	
	}

	public function action_add_hot()
	{
		$act	= $this->request->post('action');
		$words	= $this->request->post('words');

		if(empty($words))
			return false;

		if($act == 'add')
		{
			$rs = explode(',', $words);	
			
			Hotword::insert_hotword($rs);	
		}
	
		$url= '/hotword/';

		echo '<script>alert("添加成功！");window.location.href="/hotword/"</script>';
		
		exit;
	}

}
?>
